<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>todolist</title>
  <style>
      .finish{
          text-decoration: line-through;
          opacity: .5;
      }
  </style>
</head>
<body>
  <div id="main">
      <input type="text" v-model="inputValue" @keyup.enter="add">
      <button @click='add'>点击</button>
      <h3>未完成清单</h3>
      <ul>
          <li v-for = "todo in list">
              <input type="checkbox">
              <span class="{finish:todo.finished}">{{todo.text}}</span>
              <button @click="remove(todo)">删除</button>
          </li>
      </ul>
  </div>
</body>
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script>
  new Vue({
      el: '#main',
      data:{
          inputValue:'',
          list:[],  

      },
      methods:{
          add:function() {
              this.list.push({text:this.inputValue});
              this.inputValue='';
          },
          remove:function(todo) {
              this.list.splice(this.list.indexOf(todo),1)
          }
      }
  })
</script>
</html>